package com.ruoyi.seckill;


import com.ruoyi.common.security.annotation.EnableCustomConfig;
import com.ruoyi.common.security.annotation.EnableRyFeignClients;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;


import javax.annotation.PostConstruct;
import javax.sql.DataSource;
import java.sql.Connection;

/**
 * 系统模块
 *
 * @author ruoyi
 */
@EnableCustomConfig
@EnableFeignClients(basePackages = "com.ruoyi.seckill.feign")
@SpringBootApplication
@MapperScan("com.ruoyi.seckill.mapper")
public class RuoYiSeckillApplication
{

    @Autowired
    private DataSource dataSource;

    public static void main(String[] args)
    {
        SpringApplication.run(RuoYiSeckillApplication.class, args);
        System.out.println("(♥◠‿◠)ﾉﾞ  秒杀模块启动成功   ლ(´ڡ`ლ)ﾞ  \n" +
                " .-------.       ____     __        \n" +
                " |  _ _   \\      \\   \\   /  /    \n" +
                " | ( ' )  |       \\  _. /  '       \n" +
                " |(_ o _) /        _( )_ .'         \n" +
                " | (_,_).' __  ___(_ o _)'          \n" +
                " |  |\\ \\  |  ||   |(_,_)'         \n" +
                " |  | \\ `'   /|   `-'  /           \n" +
                " |  |  \\    /  \\      /           \n" +
                " ''-'   `'-'    `-..-'              ");
    }

    @PostConstruct
    public void printDataSourceInfo() {
        try (Connection conn = dataSource.getConnection()) {
            String url = conn.getMetaData().getURL();
            System.out.println("🔥 当前 DataSource URL: " + url);
        } catch (Exception e) {
            System.err.println("❌ 获取 DataSource 连接失败：" + e.getMessage());
        }
    }
}
